// import {createStore, useStore} from 'vuex'
// import {stateInt} from '@/interface/storeInterface'
//
//
//
// const state: stateInt = {
//     //推送消息
//     data: {},
//     webSocket: null,
//
// }
//
// const mutations = {
//     // 设置数据
//     setData(state, data) {
//         state.data = data;
//         console.log('数据已跟新',data)
//     },
//     // 设置 WebSocket 实例
//     setWebSocket(state, webSocket) {
//         state.webSocket = webSocket;
//     },
// };
//
// const actions = {
//     // 初始化 WebSocket
//     initWebSocket({ commit }) {
//         return new Promise<void>((resolve, reject) => {
//             const webSocket = new WebSocket('ws://192.168.1.222:8089/websockets/aibangplc/');
//
//             // 建立连接
//             webSocket.onopen = function () {
//                 console.log('通讯开始');
//                 // 发送心跳防止 WebSocket 协议自动断联
//                 setInterval(() => {
//                     webSocket.send('1');
//                 }, 1000 * 60);
//
//                 // 连接建立完成，resolve Promise
//                 resolve();
//             };
//
//             // 接收服务端消息
//             webSocket.onmessage = function (e) {
//                 // console.log('收到的数据：', e.data);
//                 const data = JSON.parse(e.data);
//                 commit('setData', data);
//             };
//
//             webSocket.onerror = function () {
//                 console.log('通讯异常');
//             };
//
//             webSocket.onclose = function () {
//                 console.log('连接已断开');
//             };
//
//             commit('setWebSocket', webSocket);
//         });
//     },
//
// };
//
// const getters = {
//     getData: (state) => state.data,
// };
//
// export default createStore({
//     state,
//     mutations,
//     actions,
//     getters,
// });


// const store = useStore();
// console.log('获取到的数据', store.getters.getData);

// const data = reactive<TrayMsg>({
//     trayInGoods: [true, true, true],
//     trayErrStatus: [false, false, false],
//     trayMouths: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
//         24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
//         48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
//         72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
//         96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
//         116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
//         135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153,
//         154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172,
//         173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191]
// })
//
// const mouthSegmentLengths = [57, 9, 21, 9, 57, 9, 21, 9]; // trayMouths每段的长度
// const inGoodsSegmentLengths = [57, 9, 21, 9, 57, 9, 21, 9]; // trayInGoods每段的长度
// const errStatusSegmentLengths = [57, 9, 21, 9, 57, 9, 21, 9]; // trayErrStatus每段的长度
// const startIndices = [0, 56, 65, 86, 95, 152, 161, 182]; // 每段的起始索引
//
// const traysData = reactive([]);
// const trayMouths = data.trayMouths;
//
// for (let i = 0; i < mouthSegmentLengths.length; i++) {
//     const mouthLength = mouthSegmentLengths[i];
//     const inGoodsLength = inGoodsSegmentLengths[i];
//     const errStatusLength = errStatusSegmentLengths[i];
//     const startIndex = startIndices[i];
//
//     const segment = {
//         trayInGoods: data.trayInGoods.slice(startIndex, startIndex + inGoodsLength),
//         trayErrStatus: data.trayErrStatus.slice(startIndex, startIndex + errStatusLength),
//         trayMouths: trayMouths.slice(startIndex, startIndex + mouthLength)
//     };
//
//     traysData.push(segment);
// }

// const traysData = reactive<TrayMsg[]>([{
//   trayInGoods: [true, true, true],
//   trayErrStatus: [false, false, false],
//   trayMouths: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
//     24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
//     48, 49, 50, 51, 52, 53, 54, 55, 56, 57]
//
// },
//   {
//     trayInGoods: [false, true, true,],
//     trayErrStatus: [false, false, false],
//     trayMouths: [58, 59, 60, 61, 62, 63, 64, 65, 66],
//   },
//   {
//     trayInGoods: [false, true, true],
//     trayErrStatus: [false, false, false],
//     trayMouths: [67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87],
//   },
//   {
//     trayInGoods: [false, true, true],
//     trayErrStatus: [false, false, false],
//     trayMouths: [88, 89, 90, 91, 92, 93, 94, 95, 96],
//   },
//   {
//     trayInGoods: [false, true, true],
//     trayErrStatus: [false, false, false],
//     trayMouths: [97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113,
//       114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132,
//       133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153],
//   },
//   {
//     trayInGoods: [false, true, true],
//     trayErrStatus: [false, false, false],
//     trayMouths: [155, 156, 157, 158, 159, 160, 161, 162, 163],
//   },
//   {
//     trayInGoods: [false, true, true, false, true, true, false, true, true],
//     trayErrStatus: [false, false, true],
//     trayMouths: [164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184],
//   },
//   {
//     trayInGoods: [false, true, true],
//     trayErrStatus: [false, false, true],
//     trayMouths: [186, 187, 188, 189, 190, 191, 192, 193, 194],
//   },
// ]);

// function moveMouths() {
//   for (let i = 0; i < traysData.length; i++) {
//     const trayMouths = traysData[i].trayMouths;
//     const trayInGoods = traysData[i].trayInGoods;
//     const trayErrStatus = traysData[i].trayErrStatus;
//     for (let j = 0; j < trayMouths.length; j++) {
//       trayMouths[j] += 1;
//       if (trayMouths[j] > maxMouth) {
//         trayMouths[j] = 1;
//       }
//
//       // 移动 trayInGoods 和 trayErrStatus 的索引
//       const nextIndex = (j + 1) % trayMouths.length;
//       trayInGoods[j] = traysData[i].trayInGoods[nextIndex];
//       trayErrStatus[j] = traysData[i].trayErrStatus[nextIndex];
//     }
//   }
// }

// 在你想要触发移动的地方，调用 moveMouths 函数
// function moveMouths() {
//   for (let i = 0; i < traysData.length; i++) {
//     const trayMouths = traysData[i].trayMouths;
//     const trayInGoods = traysData[i].trayInGoods;
//     const trayErrStatus = traysData[i].trayErrStatus;
//     for (let j = 0; j < trayMouths.length; j++) {
//       trayMouths[j] += 1;
//       if (trayMouths[j] > maxMouth) {
//         trayMouths[j] = 1;
//       }
//
//       // 移动 trayInGoods 和 trayErrStatus 的索引
//       const nextIndex = (j + 1) % trayMouths.length;
//       trayInGoods[j] = traysData[i].trayInGoods[nextIndex];
//       trayErrStatus[j] = traysData[i].trayErrStatus[nextIndex];
//
//       // 获取当前mouth的索引
//       const currentIndex = trayMouths.findIndex((mouth) => mouth === trayMouths[j]);
//
//       // 在traysCombined中查找相同mouth的项
//       const combinedItem = traysCombined.find((item) => item.mouth === trayMouths[j]);
//
//       // 如果找到匹配的项，则更新trayErrStatus和trayMouths的对应索引
//       if (combinedItem) {
//         trayErrStatus[j] = combinedItem.errStatus;
//         trayInGoods[j] = combinedItem.inGoods;
//       }
//     }
//   }
// }